//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public abstract class Effect : IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            ReadXmlCore(context);
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            WriteXmlCore(context);
        }

        #endregion

        internal static Effect ReadEffect(ReadContext context)
        {
            switch (context.ReaderLocalName)
            {
                case "alphaCeiling":
                    return context.ReadElement<AlphaCeilingEffect>();
                case "alphaBiLevel":
                    return context.ReadElement<AlphaBiLevelEffect>();
                case "alphaRepl":
                    return context.ReadElement<AlphaReplaceEffect>();
                case "clrRepl":
                    return context.ReadElement<ColorReplaceEffect>();
                case "grayscl":
                    return context.ReadElement<GrayscaleEffect>();
                case "duotone":
                    return context.ReadElement<DuotoneEffect>();
                case "clrChange":
                    return context.ReadElement<ColorChangeEffect>();
                case "cont":
                    return context.ReadElement<EffectContainer>();
                case "effect":
                    return context.ReadElement<EffectReference>();
                case "alphaFloor":
                    return context.ReadElement<AlphaFloorEffect>();
                case "alphaInv":
                    return context.ReadElement<AlphaInverseEffect>();
                case "alphaMod":
                    return context.ReadElement<AlphaModulateEffect>();
                case "alphaModFix":
                    return context.ReadElement<AlphaModulateFixedEffect>();
                case "alphaOutset":
                    return context.ReadElement<AlphaOutsetEffect>();
                case "biLevel":
                    return context.ReadElement<BiLevelEffect>();
                case "blend":
                    return context.ReadElement<BlendEffect>();
                case "blur":
                    return context.ReadElement<BlurEffect>();
                case "fill":
                    return context.ReadElement<FillEffect>();
                case "fillOverlay":
                    return context.ReadElement<FillOverlayEffect>();
                case "glow":
                    return context.ReadElement<GlowEffect>();
                case "hsl":
                    return context.ReadElement<HslEffect>();
                case "innerShdw":
                    return context.ReadElement<InnerShadowEffect>();
                case "lum":
                    return context.ReadElement<LuminanceEffect>();
                case "outerShdw":
                    return context.ReadElement<OuterShadowEffect>();
                case "prstShdw":
                    return context.ReadElement<PresetShadowEffect>();
                case "reflection":
                    return context.ReadElement<ReflectionEffect>();
                case "relOff":
                    return context.ReadElement<RelativeOffsetEffect>();
                case "softEdge":
                    return context.ReadElement<SoftEdgesEffect>();
                case "tint":
                    return context.ReadElement<TintEffect>();
                case "xfrm":
                    return context.ReadElement<TransformEffect>();
                default:
                    return null;
            }
        }

        internal abstract void ReadXmlCore(ReadContext context);

        internal abstract void WriteXmlCore(WriteContext context);
    }
}